[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
    Function OpenDatabase(FName:PathStr;DStart,DEnd:LongInt):Word;

    This opens either a standard  database  or  an InEXE database.  FName
    specifies the  file  name.   The  database  must  be  in  the current
    directory.

    Standard Databases

    DStart  and  DEnd  specify  the  start  bytes  and  end  bytes of the
    database.  The first byte  is  0,  not  1.   DEnd  must  point to the
    byte after the PPD ID  PPDATABASE.   If  the database is one file and
    does not lie  within  another  file,  you  will  usually  specify the
    start as 0 and the end as  the  file  size.   As  it is a nuisance to
    check the  file  size,  you  may  use  MaxLongInt  as  DEnd  and  the
    unit will automatically detect the file size.

    Example

    If OpenDatabase('C:\MYDATA.PPD',0,MaxLongInt)<>0 Then Halt;

    InEXE Databases

    DStart points to  the  first  byte  of  the  data in the database and
    DEnd points to the second  E  in  PPDATABASEEXE.   Because every time
    you compile your program the  signature  could  move around, there is
    an easier way of  accessing  the  database.   Simply  let  DEnd be an
    approximate position for the signature and then let

     DStart := DEnd

    The unit searches through the  file  for  the signature.  Notice that
    the unit source code is a little  peculiar.   This  is done purposely
    because the search procedure  must  not find the unit source code and
    modify that.  It must only find  the  correct  signature and thus you
    must be careful not to use the  string  'PPDATABASEEXE'  in your code
    except where the actual database exists.

    If you have a  small  EXE  file  or  have  no  clue  as  to where the
    signature lies, simply let the  variables  be  0 and the program will
    search the entire  EXE  file.   Obviously  asking  it  to search from
    100 kb deep in the file will  save  time if you know the compiler has
    placed the data near the end  of  the  file  and the EXE file is very
    large.

    Example

    If OpenDatabase('THISFILE.EXE',0,0)=0 Then
       Write('Whhheee, this is me.');

    Example (Don't do this)

    WriteLn('Using the string PPDATABASEEXE
             in the code is not at all clever.');

This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson